<?php

/**
 * Teacher form
 *
 * @version $Id: Teacher.php 73 2010-04-25 00:30:44Z yingkuang.chen@gmail.com $
 * @license New BSD License
 * @uses Zend_Form
 * @package teacher
 * @subpackage Form
 */
class Teacher_Form_Teacher extends Sfs_Form
{

	protected $_formState;
	protected $_arrayData;

	function __construct($options=null){
		$locale = Bootstrap::$config['resources']['locale']['default'];
		$path = dirname(__FILE__)."/../languages/$locale/data.ini";
		$ini = new Zend_Config_Ini($path);
		$this->_arrayData = $ini->get('array_data')->toArray();

		parent::__construct($options);
	}
	/**
	 * initialization routine
	 *
	 * @return void
	 */
	public function init()
	{
		$this->setMethod('post');
		$this->addElement('text', 'username', array(
					'label'      => 'username',
					'required'   => true,
					'filters'    => array('StringTrim','StripTags'),
					'validators' => array('NotEmpty'),
					'size'		 => 10
		)
		);
		$this->addElement('text', 'name', array(
					'label'      => 'name',
					'required'   => true,
					'filters'    => array('StringTrim'),
					'validators' => array('NotEmpty'),
					'size'		 => 10
		)
		);
		/*
		$this->addElement('text', 'sn', array(
					'label'      => 'sn',
					'required'   => true,
					'filters'    => array('StringTrim'),
		//	'validators' => array()
		)
		);
		*/
		$this->addElement('text', 'identification_number', array(
					'label'      => 'identification_number',
					'required'   => true,
					'filters'    => array('StringTrim','StringToUpper'),
					'size'		 => 10

		)
		);
		$this->getElement('identification_number')->addValidators(array(
		array('NotEmpty', true),
		array('alnum'),
		array('stringLength', false, array(10, 10)),
		));


		$this->addElement('text', 'english_name', array(
					'label'      => 'english_name',
		//  	'required'   => true,
					'filters'    => array('StringTrim'),
					'size'		 => 10
		//	'validators' => array()
		)
		);
		$this->addElement('select', 'sex', array(
					'label'      => 'sex',
					'required'   => true,
					'multiOptions'=>array('M'=>'Man','F'=>'Female'),
					'filters'    => array('StringTrim','StringToUpper'),
					'validators' => array(array('InArray',false,array(array('M','F'))))
		)
		);
		$this->addElement('text', 'birthday', array(
					'label'      => 'birthday',
					'required'   => true,
					'filters'    => array('StringTrim'),
					'validators' => array('Date'),
					'size'		 => 10
		)
		);
		$this->addElement('select', 'born_place', array(
					'label'      => 'born_place',
					'required'   => true,
					'filters'    => array('StringTrim'),
					'multiOptions'=>$this->_arrayData['born_place']
		//	'validators' => array()
		)
		);
		$this->addElement('select', 'marriaged', array(
					'label'      => 'marriaged',
		//			'required'   => true,
					'filters'    => array('StringTrim'),
					'multiOptions'=>$this->_arrayData['marriaged']
		)
		);
		$this->addElement('text', 'address', array(
					'label'      => 'address',
	//				'required'   => true,
					'filters'    => array('StringTrim'),
					'size'	=> 25
		//	'validators' => array()
		)
		);
		$this->addElement('text', 'phone_home', array(
					'label'      => 'phone_home',
					'filters'    => array('StringTrim'),
					'size'		 => 12
		//	'validators' => array()
		)
		);
		$this->addElement('text', 'phone_office', array(
					'label'      => 'phone_office',
					'filters'    => array('StringTrim'),
					'size'		 => 12
		//	'validators' => array()
		)
		);
		$this->addElement('text', 'phone_mobile', array(
					'label'      => 'phone_mobile',
					'filters'    => array('StringTrim'),
					'size'		 => 12
		//	'validators' => array()
		)
		);
		$this->addElement('text', 'website', array(
					'label'      => 'website',
					'filters'    => array('StringTrim'),
		//	'validators' => array()
		)
		);
		$this->addElement('select', 'education_level', array(
					'label'      => 'education_level',
					//'filters'    => array('StringTrim'),
					'multiOptions'=>$this->_arrayData['education_level']
		//	'validators' => array()
		)
		);
		$this->addElement('select', 'overseas', array(
					'label'      => 'overseas',
					'filters'    => array('StringTrim'),
					'multiOptions'=>$this->_arrayData['overseas'],
					//'validators' => array(array('InArray',false,array(array('Y','N'))))
		//	'validators' => array()
		)
		);
		$this->addElement('select', 'certification_type', array(
					'label'      => 'certification_type',
					'multiOPtions'=>$this->_arrayData['certification_type']
		//	'validators' => array()
		)
		);
		$this->addElement('text', 'certification_number', array(
					'label'      => 'certification_number',
					'filters'    => array('StringTrim'),
		//	'validators' => array()
		)
		);
		$this->addElement('text', 'certification_subject', array(
					'label'      => 'certification_subject',
					'filters'    => array('StringTrim'),
		//	'validators' => array()
		)
		);
		$this->addElement('select', 'disability', array(
					'label'      => 'disability',
					'required'   => true,
					'multiOptions'=>$this->_arrayData['disabilit']
		//	'validators' => array()
		)
		);
		$this->addElement('text', 'appoint_date', array(
					'label'      => 'appoint_date',
					'filters'    => array('StringTrim'),
			//		'validators' => array('Date')
		)
		);
		$this->addElement('text', 'arrive_date', array(
					'label'      => 'arrive_date',
					'filters'    => array('StringTrim'),
				//	'validators' => array('Date')
		)
		);
		$this->addElement('text', 'approve_date', array(
					'label'      => 'approve_date',
					'filters'    => array('StringTrim'),
				//	'validators' => array('Date')
		)
		);
		$this->addElement('text', 'approve_number', array(
					'label'      => 'approve_number',
					'filters'    => array('StringTrim'),
		//	'validators' => array()
		)
		);
		$this->addElement('text', 'post_number', array(
					'label'      => 'post_number',
					'filters'    => array('StringTrim'),
		//	'validators' => array()
		)
		);
		$this->addElement('text', 'bywork_number', array(
					'label'      => 'bywork_number',
					'filters'    => array('StringTrim'),
		)
		);
		$this->addElement('select', 'condition_state', array(
					'label'      => 'condition_state',
					'required'   => true,
					'multiOptions'=>$this->_arrayData['condition_state'],
		           // 'validators' => array('int')
		)
		);
		$this->addElement('select', 'current_kind_sn', array(
					'label'      => 'current_kind_sn',
					'required'   => true,
					'multiOptions'=> $this->_arrayData['current_kind_sn']
		//	'validators' => array()
		)
		);

		$teacher_title = new Teacher_Model_TeacherTitle();
		$teacher_arr = $teacher_title->getMultiOptions();
		$this->addElement('select', 'current_title_sn', array(
					'label'      => 'current_title_sn',
					'required'   => true,
					'multiOptions'=>$teacher_arr
		//	'validators' => array()
		)
		);
		$school_room = new School_Model_SchoolRoom();

		$this->addElement('select', 'current_office_id', array(
					'label'      => 'current_office_id',
					'required'   => true,
					'multiOptions' => $school_room->getKind()
		//	'validators' => array()
		)
		);

		$this->addElement('textarea', 'memo', array(
					'label'      => 'memo',
					'filters'    => array('StringTrim'),
					'cols'=>15,
					'rows'=>10
		//	'validators' => array()
		)
		);
		//$this->addElement('text', 'photo_name', array(
		//			'label'      => 'photo_name',

		//			'filters'    => array('StringTrim'),
		//	'validators' => array()
		//)
		//);
		$this->addElement('submit','save',array(
		'decorators' => $this->noElementDecorator,
		));

		$this->addDisplayGroup(array(
			'username',
			'name',
			'identification_number',
			'english_name','birthday',
			'born_place',
			'sex',
			'disability',
			'marriaged',
			'phone_home',
			'phone_office',
			'phone_mobile',
			'website',
			'address'),
			'mainForm'
			);

			$mainForm = $this->getDisplayGroup('mainForm');
			$mainForm->setDecorators(array(
			'FormElements','Fieldset',
			array('HtmlTag',array('tag'=>'div','style'=>'float:left;'))
			));
		$this->addDisplayGroup(array(
			'condition_state',
			'current_kind_sn',
			'current_title_sn',
			'current_office_id',
			'education_level',
			'overseas',
			'certification_type',
			'certification_number',
			'certification_subject',
			'appoint_date',
			'arrive_date',
			'approve_date',
			'approve_number',
			'post_number',
			'bywork_number'),
			'subForm');

			$subForm = $this->getDisplayGroup('subForm');
			$subForm->setDecorators(array(
			'FormElements','Fieldset',
			array('HtmlTag',array('tag'=>'div','style'=>'float:left;'))
			));
/*
		$this->addDisplayGroup(array(
			'memo',
			'photo_name',
			'sn','save'),
			'otherForm',
			array('legend' => 'otherForm')
			);

		$otherForm = $this->getDisplayGroup('otherForm');
		$otherForm->setDecorators(array(
			'FormElements','Fieldset',
			array('HtmlTag',array('tag'=>'div','style'=>'float:left;'))
			));

		$this->setDecorators(array(
		'FormElements',
		array('HtmlTag',array('tag'=>'div','style'=>'width:98%')),
		'Form'
		));
*/
	}


}
